﻿class cn.eminia.AS2.Flash.Table {
	var arr ;
	function Table(ori:MovieClip, AxB:String, _xd:Number, _yd:Number, dir:String, evt:Function) {
		if (ori.constructor != MovieClip) {
			throw ('错 无MC');
		}
		var xn:Number = Number(AxB.split('*')[0]);
		var yn:Number = Number(AxB.split('*')[1]);
		var num:Number = xn*yn;
		var xd:Number = (_xd == null) ? 0 : _xd;
		var yd:Number = (_yd == null) ? 0 : _yd;
		ori._visible = false;
		var ww:Number = ori._width+xd;
		var hh:Number = ori._height+yd;
		//
		arr = [];
		if (dir == '|' || dir == null) {
			for (var i = 0; i<num; i++) {
				var oo = ori.duplicateMovieClip('pp'+i, i);
				oo.txt = i;
				oo._x = i%xn*ww;
				oo._y = Math.floor(i/xn)*hh;
				evt({oo:oo, id:i});
				arr.push(oo);
			}
		} else {
			for (var i = 0; i<num; i++) {
				var oo = ori.duplicateMovieClip('pp'+i, i);
				oo.txt = i;
				oo._x = Math.floor(i/xn)*ww;
				oo._y = i%xn*hh;
				evt({oo:oo, id:i});
				arr.push(oo);
			}
		}
	}
	function killMe() {
		for (var i = 0; i<arr.length; i++) {
			removeMovieClip(arr[i]);
		}
	}
	static function Table_(con:MovieClip, xxx:String, xd:Number, yd:Number) {
		if (con.constructor != MovieClip) {
			throw ('错 无MC');
		}
		var xn = Number(xxx.split('*')[0]);
		var yn = Number(xxx.split('*')[1]);
		var num = xn*yn;
		con._visible = false;
		var ww = con._width+xd;
		var hh = con._height+yd;
		for (var i = 0; i<num; i++) {
			var oo = con.duplicateMovieClip('pp'+i, i);
			oo.txt = i;
			oo._x = Math.floor(i/xn)*ww;
			oo._y = i%xn*hh;
		}
	}
	static function Tablel(con:MovieClip, xxx:String, xd:Number, yd:Number) {
		if (con.constructor != MovieClip) {
			throw ('错 无MC');
		}
		var xn = Number(xxx.split('*')[0]);
		var yn = Number(xxx.split('*')[1]);
		var num = xn*yn;
		con._visible = false;
		var ww = con._width+xd;
		var hh = con._height+yd;
		for (var i = 0; i<num; i++) {
			var oo = con.duplicateMovieClip('pp'+i, i);
			oo.txt = i;
			oo._x = Math.floor(i/xn)*ww;
			oo._y = i%xn*hh;
		}
	}
}
